function HandleTableRowProduceMailing(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  
  this._user = (options && options.user) ? options.user : null;
  this._date = (options && options.date) ? options.date : null;
  this._produces = (options && options.produces) ? options.produces : [];
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  
  this._createElements();
};

HandleTableRowProduceMailing.prototype._createElements = function() {
  var options, model, state, transitions = [], a, checkbox, _self = this;

  a = document.createElement('a');
  a.appendChild(document.createTextNode((this._item.customerId) ? (DlmanageUtils.customerId(this._item.customerId) + this._item.orderFlag) : ''));
  if (this._user.type == Constant.USER_TYPE_MANAGER_ASSISTANT) {
    a.href = '?p=pageasst&t=pagecustomerold&m=' + JSON.stringify({ a: 2, b: 1 }) + '&opts=' + JSON.stringify({ id: this._item.customerId, track: this._item.orderTrackId });
  } else if (this._user.type == Constant.USER_TYPE_CUSTOMER_SERVICE) {
    a.href = '?p=pageserv&t=pagecustomerold&m=' + JSON.stringify({ a: 2, b: 1 }) + '&opts=' + JSON.stringify({ id: this._item.customerId, track: this._item.orderTrackId });
  } else {
    a.href = '?p=pagemanager&t=pagecustomerold&m=' + JSON.stringify({ a: 2, b: 1 }) + '&opts=' + JSON.stringify({ id: this._item.customerId, track: this._item.orderTrackId });
  }
  this._gui.customer.appendChild((this._item.customerId) ? a : document.createTextNode('Parcel'));
  
  if (this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_VIDEODVD|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_VIDEODVD_BLURAY|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_SLIDESHOW|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_SLIDESHOW_OL|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_4X6|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH_MAGAZINE|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_COMMON|escape:javascript}}') {
    var span = document.createElement('span');
    span.style.fontWeight = 'bold';
    span.appendChild(document.createTextNode(this._item.pi_quantity + 'X'));
    this._gui.name.appendChild(span);
  }
  this._gui.name.appendChild(document.createTextNode(this._item.title));
  
  if (this._item.cancelled == 0) {
    var note = document.createElement('img');
    note.src = (this._item.v2_notes.length != 0) ? 'images/buttons/note_hilight.png' : 'images/buttons/note.png';
    note.style.cursor = 'pointer';
    note.style.margin = '0 0 0 5px';
    note._produce = this._item;
    note.onclick = function() { var div, pos, func1, func2;
                                var pro = this._produce;
                                div = document.createElement('div');
                                pos = DOMUtils.findPos(this);
                                MiscUtils.dialog(_self._popupBox2, pos, div, null, null, {t: pro.title, width: 760, height: 100});
                                new DialogProduceNote(div, pro, { author: _self._user, now: _self._date, popupBox: _self._popupBox2, callbackFunc: function() { _self._callbackFunc();} });
                                return false;
                              };
    this._gui.name.appendChild(note);
  }
  
  if (this._item.pi_selects.length > 0 && (this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_4X6|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_VIDEODVD_BLURAY|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_SLIDESHOW|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_SLIDESHOW_OL|escape:javascript}}' ||
	  this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_COMMON|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH_MAGAZINE|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_ALBUM_DESIGN|escape:javascript}}')) {
    a = document.createElement('a');
    a.style.margin = '0 0 0 5px';
    a.href = '#';
    a.appendChild(document.createTextNode('Info'));
    a.onclick = function() { var func1 = function() { _self._popupBox._close(); };
                             var div = document.createElement('div');
                             MiscUtils.dialog(_self._popupBox, DOMUtils.findPos(this), div, func1, null);
                             new DialogDetails(div, _self._item, { orderId: _self._item.orderId, hidePrice: _self._options.hidePrice });
                             return false;
                           };
    this._gui.name.appendChild(a);
  }
  this._gui.user.appendChild(document.createTextNode(this._item.user_account));
  
  model = Manage.map()[this._item.pi_model];
  for (var i = 0, il = model.states.length; i < il; i++) {
    var s = model.states[i];
    if (this._item.state == s.id) {
      state = s;
      break;
    }
  }
  
  for (var i = 0, il = model.transitions.length; i < il; i++) {
    var t = model.transitions[i];
    if (this._item.state == t.source.id) {
      transitions[transitions.length] = t;
    }
  }
  
  options = MiscUtils.clone(this._options);
  options.transitions = transitions;
  options.callbackFunc = function() { _self._popupBox._close();
                                      _self._callbackFunc();
                                    };
  
  this._gui.task.appendChild(document.createTextNode(state.title));

  a = document.createElement('a');
  a.style.margin = '0 0 0 5px';
  a.href = '#';
  a.appendChild(document.createTextNode('Log'));
  a.onclick = function() { var func1 = function() { _self._popupBox2._close(); };
                           var div = document.createElement('div');
                           MiscUtils.dialog(_self._popupBox2, DOMUtils.findPos(this), div, func1, null, {t: _self._item.title, width: 820, height: 50});
                           new DialogHistory(div, _self._item, options);
                           return false;
                         };
  this._gui.task.appendChild(a);

  this._gui.dateline.style.color = (this._item.deadline && ((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) < 0) ? '#ff0000' : '#000000';
  this._gui.dateline.appendChild(document.createTextNode((this._item.deadline) ? (((((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) <= -1) || (((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) >= 0)) ? parseInt((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400, 10) : '-1') : ''));
  
  if (this._item.deadline && this._user.type == '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}') {
    a = document.createElement('a');
    a.style.margin = '0 0 0 5px';
    a.href = '#';
    a.appendChild(document.createTextNode('Chg'));
    a.onclick = function() { var context = this; var pos = DOMUtils.findPos(this);
                             _self._changeDate.call(_self, this, _self._item.deadline, function(sd) { _self._item.deadline = sd; new RequestUtils()._write('produce', [_self._item], [], function() { _self._callbackFunc();}, {php: Constant.FACTORY + '/jsonwrite.php', pos: pos}); }, false);
                             return false;
                           };
    this._gui.dateline.appendChild(a);
  }
  if (this._user.type == '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}' || this._user.type == '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}'  || this._user.type == '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}') {
    checkbox = DOMUtils.createInput(null, null, 'checkbox', null, null);
    
    var exist = false;
    for (var i = 0, il = this._produces.length; i < il; i++) {
      var p = this._produces[i];
      if (p == this._item) {
        exist = true;
      }
    }
    checkbox.defaultChecked = exist;
    checkbox.onclick = function() { if (this.checked) {
                                      _self._produces[_self._produces.length] = _self._item;
                                    } else {
                                      MiscUtils.remove(_self._produces, _self._item);
                                    }
                                  };
    this._gui.progress.appendChild(checkbox);
  } else {
    this._gui.progress.appendChild(document.createTextNode(Constant.USER_TYPE_MANAGER_ASSISTANT));
  }
};

/* 
 * 修改日期1Change
 */
HandleTableRowProduceMailing.prototype._changeDate = function(label, currentDate, onChangeFunc, showTime) {
  var div, _self = this;
  div = document.createElement('div');
  div.style.left = DOMUtils.findPos(label)[0] + 'px';
  div.style.top = DOMUtils.findPos(label)[1] + 'px';
  this._popupBox._open(div, { pos: DOMUtils.findPos(label) });
  
  var ds = new DateSelect(currentDate, null, { container: div, showTime: showTime });
  ds._selectFunc = function(sd) { _self._selectDate.call(_self, sd, label, onChangeFunc, showTime); };
};
/* 
 * 修改日期2Select
 */
HandleTableRowProduceMailing.prototype._selectDate = function(sd, label, onChangeFunc, showTime) {
  onChangeFunc(sd);
  this._showDate(sd, label, showTime);
  this._popupBox._close();
};
/* 
 * 修改日期3Show
 */
HandleTableRowProduceMailing.prototype._showDate = function(sd, label, showTime) {
  if (sd) { 
    label.value = SimpleDate.format(sd, showTime);
  } else {
    label.value = '';
  }
};